package ltd.jdsoft.cute.api.http;

import ltd.jdsoft.cute.api.StatusCodeEnum;

/**
 * 协议的元数据信息，包括响应的code和信息
 * 
 * @author zhengzhq
 *
 */
public class Meta {

  // 协议编码，详见StatusCodeEnum
  private int code;
  // 返回的数据信息，当code不等于200的时候，该值需要显示给用户看，比如字段信息填写不对
  private String message;

  public static Meta SUCCESS = new Meta(StatusCodeEnum.SUCCESS);
  public static Meta UNAUTHORIZED = new Meta(StatusCodeEnum.UNAUTHORIZED);
  public static Meta INTERNAL_SERVER_ERROR = new Meta(StatusCodeEnum.INTERNAL_SERVER_ERROR);
  public static Meta INTERNAL_BIZ_ERROR = new Meta(StatusCodeEnum.INTERNAL_BIZ_ERROR);

  public Meta(int code, String message) {
    this.code = code;
    this.message = message;
  }

  public Meta(StatusCodeEnum statusCodeEnum) {
    this(statusCodeEnum.code(), statusCodeEnum.message());
  }

  public int getCode() {
    return code;
  }

  public String getMessage() {
    return message;
  }
}
